const app = getApp()
const cnConvert = require('../../utils/changefont.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    dataList:[],
    stype:0,
    jq:'机器'
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    
    this.setData({
      stype: options.stype
    })
   var stitle = ''
   if(options.stype == 2){
     stitle = '我的加盟商'
   }else if( options.stype == 3){
     stitle = '我的合作商'
   }else{
     stitle = '我的承包商'
   }


   if (wx.getStorageSync('userDo').font == 1) { //切换繁体
     stitle = cnConvert.traditionalized(stitle)
     this.setData({
       jq: '機器'
     })
    
   }
    wx.setNavigationBarTitle({ title: stitle})
    this.getDataList();
  },
  details:function(e){
    var userid = e.currentTarget.dataset.userid;
    var usertype = e.currentTarget.dataset.type;
    wx.navigateTo({
      url: '/pages/myCoffee/myCoffee?userid=' + userid + '&usertype=' + usertype,
    })
  },
  getDataList:function(stype){
    var that = this;
    wx.request({
      url: app.globalData.api + 'getAgentListByAgentId',
      data: {
        limit: 300,
        offset: 0,
        parent: wx.getStorageSync('userDo').id,
        type: that.data.stype,
        makerSum:1,
        tfont: wx.getStorageSync('userDo').font
      },
      success:function(res){
        if (res.data.length){
          if(res.data[0].id){
            that.setData({
              dataList:res.data
            })
          }
        }
      }
    })
  }
})